<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<link href="${pageContext.request.contextPath}/css/style.css" rel="stylesheet" type="text/css"/>
<link href="${pageContext.request.contextPath}/css/table.css" rel="stylesheet" type="text/css"/>
<link href="${pageContext.request.contextPath}/dwz/themes/default/style.css" rel="stylesheet" type="text/css"
      media="screen"/>
<link href="${pageContext.request.contextPath}/dwz/themes/css/core.css" rel="stylesheet" type="text/css"
      media="screen"/>
<script src="${pageContext.request.contextPath}/jquery/jquery-2.1.4.min.js" type="text/javascript"></script>

<style>
    .licit{
        color: green;
    }
    .illegal{
        color: red;
    }
</style>
<table border="0" cellpadding="0" cellspacing="0" class="table_border">
    <tr>
        <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="0"
                   class="table_right">
                <tr>
                    <td><font style="font-size: 12px;"><strong>新增角色</strong></font>
                    </td>
                    <td width="25" height="26" align="left"></td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%" border="0" cellspacing="0" class="table_right">
                <tr>
                    <td align="center">
                        <table width="100%" border="0" cellspacing="0"
                               class="table_padding">
                            <tr>
                                <td align="center">
                                    <table border="0" cellpadding="0" cellspacing="0"
                                           class="box_table" id="box_table2">
                                        <thead>
                                        <tr>
                                            <td class="box_table_even"><span class="in">代码：</span></td>
                                            <td class="box_table_odd">
                                                <span class="in">
                                                    <input id="code" type="text"/>
                                                    <span class="star">*</span>
                                                    <span class="star" id="codeMsg"></span>
                                                </span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="box_table_even"><span class="in">名称：</span></td>
                                            <td class="box_table_odd">
                                                <span class="in">
													<input id="name" type="text"/>
                                                    <span class="star">*</span>
                                                    <span class="star" id="nameMsg"></span>
												</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="box_table_even">描述：</td>
                                            <td class="box_table_odd">
                                                <textarea id="remark" style="width: 95%" cols="100" rows="5"></textarea>
                                            </td>
                                        </tr>
                                        </thead>
                                        <tbody>
                                        </tbody>
                                    </table>
                                </td>
                            </tr>
                        </table>

                        <table border="0" cellpadding="0" cellspacing="0"
                               class="operation">
                            <thead>
                            <tr>
                                <td height="24">&nbsp;</td>
                            </tr>
                            </thead>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
    <tr>
        <td>
            <table width="100%" border="0" cellpadding="0" cellspacing="0"
                   class="table_padding">
                <tr>
                    <td height="21" align="right">
                        <table align="left">
                            <tr>
                                <td width="50px"><a class="button" onclick="save()"
                                                    href="javascript:void (0)"><span>保存</span></a></td>
                                <td width="50px"><a class="button"
                                                    href="javascript:void(window.history.back());"><span>返回</span></a>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<script src="${pageContext.request.contextPath}/lib/roleUtils.js" type="text/javascript"></script>
<script>
    function save() {
        let id = $("#id").val();
        let name = $("#name").val();
        let code = $("#code").val();
        let remark = $("#remark").val();

        let flag = lashVerifyRole(code,name);
        if (!flag){
            alert("非法数据,请检查");
            return;
        }

        $.ajax({
            type: "post",
            async: false,
            url: "${pageContext.request.contextPath}/role?method=save",
            dataType: "json",
            data: {
                "id": id,
                "name": name,
                "code": code,
                "remake": remark
            },
            success: function (result) {
                if (result.code == "200") {
                    location.href = "${pageContext.request.contextPath}/role?method=getRolePage";
                } else {
                    alert(result.message);
                }
            }
        });
    }
</script>

